//
//  WBBaseViewController.swift
//  Weibo
//
//  Created by 张俭 on 16/8/17.
//  Copyright © 2016年 张俭. All rights reserved.
//

import UIKit
class WBBaseViewController: UIViewController {
    fileprivate let userLogon = false
    var visitorInfo : [String:AnyObject]? 
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    ///登录
    @objc fileprivate func login(){
        
        print(#function)
    }
    ///注册
    @objc fileprivate func register(){
        print(#function)
    }

    
    
    
}
// MARK: - 初始化
private extension WBBaseViewController {
    func setupUI() {
        view.backgroundColor = UIColor.random();
        
        userLogon ? setupTableView() : setupVisitorView()
    }
}

// MARK: - 公共方法 给子类使用
private extension WBBaseViewController {
    func setupVisitorView() {
        
        let visitorView = WBVisitorView.visitorView()
        visitorView.visitorInfo = visitorInfo
        visitorView.frame = view.bounds
        view.addSubview(visitorView)
        
        visitorView.loginButton.addTarget(self, action: #selector(login), for: .touchUpInside)
        visitorView.registerButton.addTarget(self, action: #selector(register), for: .touchUpInside)
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .plain, target: self, action: #selector(login))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action: #selector(register))
        
    }
    func setupTableView() {
    }
}
